package com.wondersgroup.ndkdemo;

import android.location.GpsSatellite;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.hss.libpatch.BsPatch;
//import com.hss.splitfile.SplitFile;

import java.io.File;

//import com.hss.danymicloadso.FileUtil;

//import com.wondersgroup.mylibrary.Util;

public class MainActivity extends AppCompatActivity {


    TextView tv_name;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        int [] arr = {20, 10, 3, 4, 7, 345, 567, 34, 46};
//        Util util = new Util();
//        int value = util.getAddValue(3, 6);

        tv_name = (TextView) findViewById(R.id.tv_name);
        tv_name.setOnClickListener(clickListener);
//        tv_name.setText(Util.getStringFromC()+Util.count);
//        util.processArr(arr);
//        for (int i = 0, size = arr.length; i < size; i++) {
//            Log.e("MainActivity", "arr[" + i + "] = " + value);
//        }
//        util.chineseChars("委屈翁无群二群");
//        Log.e("MainActivity", "value = " + value);
//        String [] arrr= util.initStringArray(20);
//        for (int i=0,size=arr.length;i<size;i++){
//            Log.e("arr", "["+i +"] = "+arr[i]);
//        }

//        util.sortArrary(arr);
//        printArr(arr);

//        util.createGlobalref();
//        util.delGlobalref();

//        try {
//            util.exception();
//
//        }catch (Exception e){
//            Log.e("",e.getMessage());
//        }


//        util.gloablCached();

//        FileUtil fileUtil = new FileUtil();
//        fileUtil.diff("a","c",45);
//        splitFile.setJniEnv();


    }

    <T>void  printArr(T[] arr){
        for (int i=0,size=arr.length;i<size;i++){
            Log.e("arr", "["+i +"] = "+arr[i]);
        }
    }

    void  printArr(int[] arr){
        for (int i=0,size=arr.length;i<size;i++){
            Log.e("arr", "["+i +"] = "+arr[i]);
        }
    }


    String SD_PATH = Environment.getExternalStorageDirectory().getAbsolutePath();
    View.OnClickListener clickListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
//            thread();
            Log.e("click","end");
            patch();
        }
    };

//    void diff(){
//        String path = SD_PATH+ File.separator+"aa.mp4";
//        String parrern_path= SD_PATH+ File.separator+"aa_%d.mp4";
//        SplitFile.diff(path,parrern_path,4);
//
//    }
//
//    void merge(){
//        String path = SD_PATH+ File.separator+"aa_merge.mp4";
//        String parrern_path= SD_PATH+ File.separator+"aa_%d.mp4";
//        SplitFile.merge(path,parrern_path,4);
//
//    }
//    SplitFile splitFile = new SplitFile();
//    void thread(){
//        splitFile.newJniThread();
//    }

    String oldapkpath = SD_PATH+ File.separator+"yfy_218_jiagu_sign.apk";
    String newapkpath = SD_PATH+ File.separator+"yfy_219.apk";
    String patchpath = SD_PATH+ File.separator+"yfy.patch";

    void patch(){
        new Thread(new Runnable() {
            @Override
            public void run() {
                int result = BsPatch.patch(oldapkpath,newapkpath,patchpath);
                Log.e("","result = "+ result);
            }
        }).start();

    }


}
